package com.aramco.fion.util
{	
	import com.aramco.fion.vo.ComponentAssignmentVO;
	import com.aramco.fion.vo.ComponentTypeVO;
	import com.aramco.fion.vo.ComponentVO;
	import com.aramco.fion.vo.DashboardVo;
	import com.aramco.fion.vo.dateVO;
	
	import flashx.textLayout.operations.CopyOperation;

	public final class AdminUtil
	{
		public static var db:DashboardVo;
		
		public static var cmp:ComponentVO;
		
		public static var type:ComponentTypeVO;
		public static var assign:ComponentAssignmentVO;
		
		
		
		public static var dashboardTableFields:Array = ['DB_ID','TITLE','DESCRIPTION','LOGO','ADMIN_ROLE'
												,'CREATED_BY','CREATED_DATE','CHANGED_BY','CHANGED_DATE','NOT_ACTIVE','HIDE','ZORDER'];
		
		public static var viewTableFields:Array = ['VIEW_ID','DB_ID','TITLE','DESCRIPTION','VIEW_TYPE','LAYOUT'
											,'AUDIANCE','CREATED_BY','CREATED_DATE','CHANGED_BY','CHANGED_DATE','NOT_ACTIVE','ZORDER'];	
		
		public static var compTableFields:Array = ['COMP_ID','DB_ID','TITLE','DESCRIPTION','COMP_TYPE','QUERY','CREATED_BY','CREATED_DATE',
													'CHANGED_BY','CHANGED_DATE','NOT_ACTIVE','NOTE','DRILL_TO','DRILL_VARS','OPTIONS','MOBILE',
													'ZSCHEDULE','URL'];
		
		
		public static function parseDashboardXML(xmlObject:Object):DashboardVo
		{
			db = new DashboardVo();
			 
			db.id = xmlObject.DB_ID;
			db.title = xmlObject.TITLE;
			db.description = xmlObject.DESCRIPTION;
			db.logoUrl = xmlObject.LOGO;
			db.role = xmlObject.ADMIN_ROLE;
			db.zorder = xmlObject.ZORDER;
			db.notActive = xmlObject.NOT_ACTIVE == 'X' ? true: false;
			db.hidden = xmlObject.HIDE == 'X' ? true: false;
			db.createdBy = xmlObject.CREATED_BY;
			db.createdOn = new dateVO(xmlObject.CREATED_DATE);
			db.changedBy = xmlObject.CHANGED_BY_BY;
			db.changedOn = new dateVO(xmlObject.CREATED_DATE); 
			 
			 return db;
		}
		
		
		
		public static function parseComponentXML(xmlObject:Object):ComponentVO
		{
			cmp = new ComponentVO();
			
			cmp.id = xmlObject.COMP_ID;
			cmp.title = xmlObject.TITLE;
			cmp.description = xmlObject.DESCRIPTION;
			cmp.schedule = xmlObject.schedule;
			cmp.type = xmlObject.COMP_TYPE;
			cmp.zorder = xmlObject.ZORDER;
			cmp.notActive = xmlObject.NOT_ACTIVE == 'X' ? true: false;
			cmp.schedule = xmlObject.ZSCHEDULE == 'X' ? true: false;
			cmp.mobile = xmlObject.MOBILE == 'X' ? true: false;
			cmp.url = xmlObject.URL;
			cmp.options = xmlObject.OPTIONS;
			cmp.queryName = xmlObject.QUERY;
			cmp.dashboardId = xmlObject.DB_ID;
			cmp.createdBy = xmlObject.CREATED_BY;
			cmp.createdOn = new dateVO(xmlObject.CREATED_DATE);
			cmp.changedBy = xmlObject.CHANGED_BY_BY;
			cmp.changedOn = new dateVO(xmlObject.CREATED_DATE); 
			
			return cmp;
		}
		
		public static function parseCompToViewAssignmentXML(xmlObject:Object):ComponentAssignmentVO
		{
			assign = new ComponentAssignmentVO(xmlObject.VIEW_ID,xmlObject.COMP_ID,xmlObject.ZORDER);
			assign.createdBy = xmlObject.CREATED_BY;
			assign.createdOn = new dateVO(xmlObject.CREATED_DATE);
			assign.changedBy = xmlObject.CHANGED_BY_BY;
			assign.changedOn = new dateVO(xmlObject.CREATED_DATE); 
			
			return assign;
		}
		
		public static function parseComponentTypeXML(xmlObject:Object):ComponentTypeVO
		{
			type = new ComponentTypeVO();
			
			type.type = xmlObject.COMP_TYPE;
			type.description = xmlObject.DESCRIPTION;
			type.notActive = xmlObject.NOT_ACTIVE == 'X' ? true: false;
			type.createdBy = xmlObject.CREATED_BY;
			type.createdOn = new dateVO(xmlObject.CREATED_DATE);
			type.changedBy = xmlObject.CHANGED_BY_BY;
			type.changedOn = new dateVO(xmlObject.CREATED_DATE); 
			
			return type;
		}
		
	}
}
